<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<title>同义词格式 | Elasticsearch: 权威指南 | Elastic</title>
    <!-- Give IE8 a fighting chance -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
	<link rel="stylesheet" type="text/css" href="../static/styles.css" />
</head>
<body>
<div class="main-container">
    <section id="content">
        
        <div class="content-wrapper">
            <section id="guide" lang="zh_cn">
                <div class="container">
                    <div class="row">
                        <div class="col-xs-12 col-sm-8 col-md-8 guide-section">
                            <div style="color:gray; word-break: break-all; font-size:12px;">原文地址: <a href="https://www.elastic.co/guide/cn/elasticsearch/guide/current/synonym-formats.html" rel="nofollow">https://www.elastic.co/guide/cn/elasticsearch/guide/current/synonym-formats.html</a>, 版权归 www.elastic.co 所有<br/>
                            英文版地址: <a href="https://www.elastic.co/guide/en/elasticsearch/guide/current/synonym-formats.html" rel="nofollow">https://www.elastic.co/guide/en/elasticsearch/guide/current/synonym-formats.html</a>
                            </div>
                        <!-- start body -->
                  <div class="page_header">
<b>请注意:</b><br>本书基于 Elasticsearch 2.x 版本，有些内容可能已经过时。
</div>
<div id="content">
<div class="breadcrumbs">
<span class="breadcrumb-link"><a href="index.html">Elasticsearch: 权威指南</a></span>
»
<span class="breadcrumb-link"><a href="languages.html">处理人类语言</a></span>
»
<span class="breadcrumb-link"><a href="synonyms.html">同义词</a></span>
»
<span class="breadcrumb-node">同义词格式</span>
</div>
<div class="navheader">
<span class="prev">
<a href="using-synonyms.html">« 使用同义词</a>
</span>
<span class="next">
<a href="synonyms-expand-or-contract.html">扩展或收缩 »</a>
</span>
</div>
<div class="section">
<div class="titlepage"><div><div>
<h2 class="title">
<a id="synonym-formats"></a>同义词格式<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elasticsearch-cn/elasticsearch-definitive-guide/edit/cn/260_Synonyms/30_Synonym_formats.asciidoc">edit</a>
</h2>
</div></div></div>
<p>同义词最简单的表达形式是  逗号分隔：</p>
<pre class="literallayout">"jump,leap,hop"</pre>

<p>如果遇到这些词项中的任何一项，则将其替换为所有列出的同义词。例如：</p>
<div class="pre_wrapper lang-text pagebreak-before">
<pre class="programlisting prettyprint lang-text pagebreak-before">原始词项:   取代:
────────────────────────────────
jump            → (jump,leap,hop)
leap            → (jump,leap,hop)
hop             → (jump,leap,hop)</pre>
</div>
<p>或者, 使用 <code class="literal">=&gt;</code> 语法，可以指定一个词项列表（在左边），和一个或多个替换（右边）的列表：</p>
<pre class="literallayout">"u s a,united states,united states of america =&gt; usa"
"g b,gb,great britain =&gt; britain,england,scotland,wales"</pre>

<div class="pre_wrapper lang-text">
<pre class="programlisting prettyprint lang-text">原始词项:   取代:
────────────────────────────────
u s a           → (usa)
united states   → (usa)
great britain   → (britain,england,scotland,wales)</pre>
</div>
<p>如果多个规则指定同一个同义词，它们将被合并在一起，且顺序无关，否则使用最长匹配。以下面的规则为例：</p>
<pre class="literallayout">"united states            =&gt; usa",
"united states of america =&gt; usa"</pre>

<p>如果这些规则相互冲突，Elasticsearch 会将 <code class="word">United States of America</code> 转换为词项 <code class="word">(usa),(of),(america)</code> 。否则，会使用最长的序列，即最终得到词项 <code class="word">(usa)</code> 。</p>
</div>
<div class="navfooter">
<span class="prev">
<a href="using-synonyms.html">« 使用同义词</a>
</span>
<span class="next">
<a href="synonyms-expand-or-contract.html">扩展或收缩 »</a>
</span>
</div>
</div>

                  <!-- end body -->
                        </div>
                        <div class="col-xs-12 col-sm-4 col-md-4" id="right_col">
                        
                        </div>
                    </div>
                </div>
            </section>
        </div>
    </section>
</div>
<script src="../static/cn.js"></script>
</body>
</html>